import { HeroDetailComponent } from './hero-detail/hero-detail.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { HeroesComponent } from './heroes/heroes.component';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [

  { path:'heroes', component:HeroesComponent},
  { path:'dashboard', component:DashboardComponent},
  { path:'detail/:id', component:HeroDetailComponent},


  /**
   * pathMatch:'full'指的是必须与路径完全匹配才会跳转
   *     另一个参数'prefix'是指路径中有path就可以
   * 举个例子： { path:'a',redirectTo:'/dialog',pathMatch:'prefix'},
   * 1.http://localhost:9800/a
     2.http://localhost:9800/a/sadf/adfs/
     都会被重定向，但是
     http://localhost:9800/asdfsdf ---不可以
   *  */
  { path:'**', redirectTo:'/dashboard', pathMatch:'full'}


];

@NgModule({
  // forRoot 这么命名是因为我实在顶层(根部)配置路由的，这个方法可以提供给路由服务提供着和指令
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
